package com.augurit.gzcgwsp.smartformCsdlwj.convert;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.dozer.DozerBeanMapper;

import com.augurit.gzcgwsp.sendNotice.exchangedatatofx.entity.YwGgcsForFx;
import com.augurit.gzcgwsp.smartformCsdlwj.entity.YwGgcs;
import com.augurit.gzcgwsp.smartformCsdlwj.entity.YwSrDlzy;
import com.augurit.gzcgwsp.smartformCsdlwj.web.form.GgcsForm;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxForm;

/**
 * 公共厕所审批
 * @author Administrator
 *
 */
 
public class YwSrGgcsConvertor {
    public static GgcsForm convertVoToForm(YwGgcs entity) {
        if (entity == null) return null;
        GgcsForm form = new DozerBeanMapper().map(entity, GgcsForm.class);        
        return form;
    }
    
    public static void convertFormToQyxxForm(GgcsForm form, YwComQyxxForm qyxxForm) {
        if (form == null) return;
        if (qyxxForm == null) qyxxForm = new YwComQyxxForm();

        new DozerBeanMapper().map(form, qyxxForm);
        if(StringUtils.isNotBlank(form.getQybh())){
        	qyxxForm.setId(Long.parseLong(form.getQybh()));
        }        
    }

    public static void convertQyxxFormToForm(YwComQyxxForm qyxxForm, GgcsForm form) {
        if (qyxxForm == null) return;
        if (form == null) form = new GgcsForm();
        
        new DozerBeanMapper().map(qyxxForm, form);
        form.setQybh(qyxxForm.getId().toString());
    }
    
    public static void convertFormToVo(GgcsForm form, YwGgcs entity) {
        if (form == null) return;
        //if (entity == null) entity = new YwSrDlzy();
        
        new DozerBeanMapper().map(form, entity);
    }
    
    public static List<GgcsForm> convertVoListToFormList(List<YwGgcs> ywSrGgcsList) {
        if(ywSrGgcsList != null && ywSrGgcsList.size() > 0) {
            List<GgcsForm> ggcsFormList = new ArrayList();
            for(int i=0; i<ywSrGgcsList.size(); i++) {
            	ggcsFormList.add(convertVoToForm(ywSrGgcsList.get(i)));
            }
            return ggcsFormList;
        }
        return null;
    }
    
    public static List<YwGgcs> convertFormListToVoList(List<GgcsForm> ggcsFormList) {
        if(ggcsFormList != null && ggcsFormList.size() > 0) {
            List<YwGgcs> ywGgcsList = new ArrayList();
            for(int i=0; i<ggcsFormList.size(); i++) {
            	YwGgcs ywGgcs = new YwGgcs();
                convertFormToVo(ggcsFormList.get(i), ywGgcs);
                ywGgcsList.add(ywGgcs);
            }
            return ywGgcsList;
        }
        return null;
    }
    
    public static void convertFormToYwGgcsForFx(GgcsForm form, YwGgcsForFx entity) {
        if (form == null) return;
        if (entity == null) entity = new YwGgcsForFx();        
        new DozerBeanMapper().map(form, entity);
    }
}